const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const WeatherForecast = sequelize.define('WeatherForecast', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  city: {
    type: DataTypes.STRING(100),
    allowNull: false,
    comment: '城市名称',
    index: true
  },
  date: {
    type: DataTypes.DATEONLY,
    allowNull: false,
    comment: '预报日期'
  },
  week: {
    type: DataTypes.STRING(10),
    allowNull: false,
    comment: '星期'
  },
  dayweather: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '白天天气'
  },
  nightweather: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '夜间天气'
  },
  daytemp: {
    type: DataTypes.STRING(10),
    allowNull: false,
    comment: '白天温度'
  },
  nighttemp: {
    type: DataTypes.STRING(10),
    allowNull: false,
    comment: '夜间温度'
  },
  daywind: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '白天风向'
  },
  nightwind: {
    type: DataTypes.STRING(50),
    allowNull: false,
    comment: '夜间风向'
  },
  daypower: {
    type: DataTypes.STRING(10),
    allowNull: false,
    comment: '白天风力'
  },
  nightpower: {
    type: DataTypes.STRING(10),
    allowNull: false,
    comment: '夜间风力'
  }
}, {
  tableName: 'weather_forecast',
  comment: '天气预报表',
  indexes: [
    {
      name: 'idx_city',
      fields: ['city']
    }
  ]
});

module.exports = WeatherForecast; 